﻿using System.Threading;
using DimensionsHelper.Common.Contracts.Excel;
using DimensionsHelper.Common.Contracts.Services;

namespace DimensionsHelper.Common.Contracts.DataCollector;

public interface IExcelReader : IProjectService
{
    /// <summary>
    ///     配置Excel读取器的详细配置。
    /// </summary>
    /// <param name="options"></param>
    void SetOptions(object options);

    /// <summary>
    ///     获取指定类型的数据。
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <returns>转换类型后的数据，是否抛出错误由实现类型决定。</returns>
    T GetData<T>();

    /// <summary>
    ///     读取Excel中的数据。
    /// </summary>
    /// <param name="workbook">已打开的电子文档</param>
    /// <param name="index">文件数据索引</param>
    /// <param name="expression">用作类型筛选器的表达式</param>
    void ReadExcel(IExcelWorkbookOperator workbook, int index, string? expression);

    /// <summary>
    ///     <inheritdoc cref="ReadExcel(IExcelWorkbookOperator, int, string?)" />
    /// </summary>
    /// <param name="workbook">已打开的电子文档</param>
    /// <param name="cancellationToken">当前线程的取消令牌</param>
    /// <param name="index">文件数据索引</param>
    /// <param name="expression">用作类型筛选器的表达式</param>
    void ReadExcel(IExcelWorkbookOperator workbook, int index, string? expression,
        CancellationToken cancellationToken);

    /// <summary>
    ///     清空已读取的内容。
    /// </summary>
    void Clear();
}